package com.cal.utms.entity;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the deal_instrument_map database table.
 * 
 */
@Entity
@Table(name="deal_instrument_map")
@NamedQuery(name="DealInstrumentMap.findAll", query="SELECT d FROM DealInstrumentMap d")
public class DealInstrumentMap implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(unique=true, nullable=false)
	private int id;

	@Temporal(TemporalType.DATE)
	private Date date;

	@Column(length=45)
	private String status;

	//bi-directional many-to-one association to Deal
	@ManyToOne
	@JoinColumn(name="DEAL_ID")
	private Deal deal;

	//uni-directional many-to-one association to Instrument
	@ManyToOne
	@JoinColumn(name="INSTRUMENT_ID")
	private Instrument instrument;

	//bi-directional many-to-one association to InstrumentTransaction
	@OneToMany(mappedBy="dealInstrumentMap", fetch = FetchType.EAGER)
	@Fetch(value = FetchMode.SUBSELECT)
	private List<InstrumentTransaction> instrumentTransactions;

	public DealInstrumentMap() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Deal getDeal() {
		return this.deal;
	}

	public void setDeal(Deal deal) {
		this.deal = deal;
	}

	public Instrument getInstrument() {
		return this.instrument;
	}

	public void setInstrument(Instrument instrument) {
		this.instrument = instrument;
	}

	public List<InstrumentTransaction> getInstrumentTransactions() {
		return this.instrumentTransactions;
	}

	public void setInstrumentTransactions(List<InstrumentTransaction> instrumentTransactions) {
		this.instrumentTransactions = instrumentTransactions;
	}

	public InstrumentTransaction addInstrumentTransaction(InstrumentTransaction instrumentTransaction) {
		getInstrumentTransactions().add(instrumentTransaction);
		instrumentTransaction.setDealInstrumentMap(this);

		return instrumentTransaction;
	}

	public InstrumentTransaction removeInstrumentTransaction(InstrumentTransaction instrumentTransaction) {
		getInstrumentTransactions().remove(instrumentTransaction);
		instrumentTransaction.setDealInstrumentMap(null);

		return instrumentTransaction;
	}

}